﻿@model ShippingSettingsModel

@{
    //page title
    ViewBag.Title = T("Admin.Configuration.Settings.Shipping").Text;
    //active menu item (system name)
    Html.SetActiveMenuItemSystemName("Shipping settings");
}

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    <div class="content-header clearfix">
        <h1 class="pull-left">
            @T("Admin.Configuration.Settings.Shipping")
        </h1>
        <div class="pull-right">
            <button type="submit" name="save" class="btn bg-blue">
                <i class="fa fa-floppy-o"></i>
                @T("Admin.Common.Save")
            </button>
        </div>
    </div>


    <div class="content">
        <div class="form-horizontal">
            @Html.Action("ProjectScopeConfiguration", "Setting")
            @Html.Action("Mode", "Setting")
            @Html.ValidationSummary(false)

            <div class="panel-group">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.OverrideProjectCheckboxFor(model => model.AllowPickUpInProject_OverrideForProject, model => model.AllowPickUpInProject, Model.ActiveProjectScopeConfiguration)
                                @Html.SDFLabelFor(model => model.AllowPickUpInProject)
                            </div>
                            <div class="col-md-9">
                                @Html.SDFEditorFor(model => model.AllowPickUpInProject)
                                @Html.ValidationMessageFor(model => model.AllowPickUpInProject)
                            </div>
                        </div>
                        <div class="form-group advanced-setting" id="pnlDisplayPickupPointsOnMap">
                            <div class="col-md-3">
                                @Html.OverrideProjectCheckboxFor(model => model.DisplayPickupPointsOnMap_OverrideForProject, model => model.DisplayPickupPointsOnMap, Model.ActiveProjectScopeConfiguration)
                                @Html.SDFLabelFor(model => model.DisplayPickupPointsOnMap)
                            </div>
                            <div class="col-md-9">
                                @Html.SDFEditorFor(model => model.DisplayPickupPointsOnMap)
                                @Html.ValidationMessageFor(model => model.DisplayPickupPointsOnMap)
                            </div>
                        </div>
                        <div class="form-group advanced-setting" id="pnlGoogleMapsApiKey">
                            <div class="col-md-3">
                                @Html.OverrideProjectCheckboxFor(model => model.GoogleMapsApiKey_OverrideForProject, model => model.GoogleMapsApiKey, Model.ActiveProjectScopeConfiguration)
                                @Html.SDFLabelFor(model => model.GoogleMapsApiKey)
                            </div>
                            <div class="col-md-9">
                                @Html.SDFEditorFor(model => model.GoogleMapsApiKey)
                                @Html.ValidationMessageFor(model => model.GoogleMapsApiKey)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.OverrideProjectCheckboxFor(model => model.FreeShippingOverXEnabled_OverrideForProject, model => model.FreeShippingOverXEnabled, Model.ActiveProjectScopeConfiguration)
                                @Html.SDFLabelFor(model => model.FreeShippingOverXEnabled)
                            </div>
                            <div class="col-md-9">
                                @Html.SDFEditorFor(model => model.FreeShippingOverXEnabled)
                                @Html.ValidationMessageFor(model => model.FreeShippingOverXEnabled)
                            </div>
                        </div>
                        <div class="form-group" id="pnlValueOfX">
                            <div class="col-md-3">
                                @Html.OverrideProjectCheckboxFor(model => model.FreeShippingOverXValue_OverrideForProject, model => model.FreeShippingOverXValue, Model.ActiveProjectScopeConfiguration)
                                @Html.SDFLabelFor(model => model.FreeShippingOverXValue)
                            </div>
                            <div class="col-md-9">
                                @Html.SDFEditorFor(model => model.FreeShippingOverXValue)
                                @Html.ValidationMessageFor(model => model.FreeShippingOverXValue)
                            </div>
                        </div>
                        <div class="form-group advanced-setting" id="pnlValueOfXincltax">
                            <div class="col-md-3">
                                @Html.OverrideProjectCheckboxFor(model => model.FreeShippingOverXIncludingTax_OverrideForProject, model => model.FreeShippingOverXIncludingTax, Model.ActiveProjectScopeConfiguration)
                                @Html.SDFLabelFor(model => model.FreeShippingOverXIncludingTax)
                            </div>
                            <div class="col-md-9">
                                @Html.SDFEditorFor(model => model.FreeShippingOverXIncludingTax)
                                @Html.ValidationMessageFor(model => model.FreeShippingOverXIncludingTax)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.OverrideProjectCheckboxFor(model => model.EstimateShippingEnabled_OverrideForProject, model => model.EstimateShippingEnabled, Model.ActiveProjectScopeConfiguration)
                                @Html.SDFLabelFor(model => model.EstimateShippingEnabled)
                            </div>
                            <div class="col-md-9">
                                @Html.SDFEditorFor(model => model.EstimateShippingEnabled)
                                @Html.ValidationMessageFor(model => model.EstimateShippingEnabled)
                            </div>
                        </div>
                        <div class="form-group advanced-setting">
                            <div class="col-md-3">
                                @Html.OverrideProjectCheckboxFor(model => model.ShipToSameAddress_OverrideForProject, model => model.ShipToSameAddress, Model.ActiveProjectScopeConfiguration)
                                @Html.SDFLabelFor(model => model.ShipToSameAddress)
                            </div>
                            <div class="col-md-9">
                                @Html.SDFEditorFor(model => model.ShipToSameAddress)
                                @Html.ValidationMessageFor(model => model.ShipToSameAddress)
                            </div>
                        </div>
                        <div class="form-group advanced-setting">
                            <div class="col-md-3">
                                @Html.OverrideProjectCheckboxFor(model => model.UseWarehouseLocation_OverrideForProject, model => model.UseWarehouseLocation, Model.ActiveProjectScopeConfiguration)
                                @Html.SDFLabelFor(model => model.UseWarehouseLocation)
                            </div>
                            <div class="col-md-9">
                                @Html.SDFEditorFor(model => model.UseWarehouseLocation)
                                @Html.ValidationMessageFor(model => model.UseWarehouseLocation)
                            </div>
                        </div>
                        <div class="form-group advanced-setting">
                            <div class="col-md-3">
                                @Html.OverrideProjectCheckboxFor(model => model.NotifyCustomerAboutShippingFromMultipleLocations_OverrideForProject, model => model.NotifyCustomerAboutShippingFromMultipleLocations, Model.ActiveProjectScopeConfiguration)
                                @Html.SDFLabelFor(model => model.NotifyCustomerAboutShippingFromMultipleLocations)
                            </div>
                            <div class="col-md-9">
                                @Html.SDFEditorFor(model => model.NotifyCustomerAboutShippingFromMultipleLocations)
                                @Html.ValidationMessageFor(model => model.NotifyCustomerAboutShippingFromMultipleLocations)
                            </div>
                        </div>
                        <div class="form-group advanced-setting">
                            <div class="col-md-3">
                                @Html.OverrideProjectCheckboxFor(model => model.DisplayShipmentEventsToCustomers_OverrideForProject, model => model.DisplayShipmentEventsToCustomers, Model.ActiveProjectScopeConfiguration)
                                @Html.SDFLabelFor(model => model.DisplayShipmentEventsToCustomers)
                            </div>
                            <div class="col-md-9">
                                @Html.SDFEditorFor(model => model.DisplayShipmentEventsToCustomers)
                                @Html.ValidationMessageFor(model => model.DisplayShipmentEventsToCustomers)
                            </div>
                        </div>
                        <div class="form-group advanced-setting">
                            <div class="col-md-3">
                                @Html.OverrideProjectCheckboxFor(model => model.DisplayShipmentEventsToProjectOwner_OverrideForProject, model => model.DisplayShipmentEventsToProjectOwner, Model.ActiveProjectScopeConfiguration)
                                @Html.SDFLabelFor(model => model.DisplayShipmentEventsToProjectOwner)
                            </div>
                            <div class="col-md-9">
                                @Html.SDFEditorFor(model => model.DisplayShipmentEventsToProjectOwner)
                                @Html.ValidationMessageFor(model => model.DisplayShipmentEventsToProjectOwner)
                            </div>
                        </div>
                        <div class="form-group advanced-setting">
                            <div class="col-md-3">
                                @Html.OverrideProjectCheckboxFor(model => model.BypassShippingMethodSelectionIfOnlyOne_OverrideForProject, model => model.BypassShippingMethodSelectionIfOnlyOne, Model.ActiveProjectScopeConfiguration)
                                @Html.SDFLabelFor(model => model.BypassShippingMethodSelectionIfOnlyOne)
                            </div>
                            <div class="col-md-9">
                                @Html.SDFEditorFor(model => model.BypassShippingMethodSelectionIfOnlyOne)
                                @Html.ValidationMessageFor(model => model.BypassShippingMethodSelectionIfOnlyOne)
                            </div>
                        </div>
                    </div>
                    <script type="text/javascript">
                        $(document).ready(function() {
                            $("#@Html.FieldIdFor(model => model.AllowPickUpInProject)").click(toggleAllowPickUpInProject);
                            $("#@Html.FieldIdFor(model => model.DisplayPickupPointsOnMap)").click(toggleAllowPickUpInProject);
                            $("#@Html.FieldIdFor(model => model.FreeShippingOverXEnabled)").click(toggleFreeShippingOverX);
                            toggleAllowPickUpInProject();
                            toggleFreeShippingOverX();
                        });

                        function toggleAllowPickUpInProject() {
                            if ($('#@Html.FieldIdFor(model => model.AllowPickUpInProject)').is(':checked')) {
                                $('#pnlDisplayPickupPointsOnMap').show();
                                if ($('#@Html.FieldIdFor(model => model.DisplayPickupPointsOnMap)').is(':checked')) {
                                    $('#pnlGoogleMapsApiKey').show();
                                } else {
                                    $('#pnlGoogleMapsApiKey').hide();
                                }
                            } else {
                                $('#pnlDisplayPickupPointsOnMap').hide();
                                $('#pnlGoogleMapsApiKey').hide();
                            }
                        }

                        function toggleFreeShippingOverX() {
                            if ($('#@Html.FieldIdFor(model => model.FreeShippingOverXEnabled)').is(':checked')) {
                                $('#pnlValueOfX').show();
                                $('#pnlValueOfXincltax').show();
                            } else {
                                $('#pnlValueOfX').hide();
                                $('#pnlValueOfXincltax').hide();
                            }
                        }

                    </script>
                </div>
                <div class="panel panel-default">
                    <div class="panel-heading">
                        @Html.OverrideProjectCheckboxFor(model => model.ShippingOriginAddress_OverrideForProject, "pnlShippingOriginAddress", Model.ActiveProjectScopeConfiguration)
                        @T("Admin.Configuration.Settings.Shipping.ShippingOriginAddress")
                    </div>
                    <div class="panel-body">
                        <div id="pnlShippingOriginAddress">
                            @Html.EditorFor(x => x.ShippingOriginAddress, "Address")
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
}
